﻿using DDD.Application;
using GoodsModule.Application.Commands;
using GoodsModule.Domain.GoodsCategoryDomainEvents;
using MediatR;
using Microsoft.Extensions.Logging;

namespace GoodsModule.Application.DomainEvents
{
    internal class GoodsCategoryDeletedDomainEventHandler(
        IMediator mediator,
        ILogger<GoodsCategoryDeletedDomainEventHandler> logger)
        : IDomainEventHandler<GoodsCategoryDeletedDomainEvent>
    {
        public Task Handle(GoodsCategoryDeletedDomainEvent @event, CancellationToken cancellationToken)
        {
            var cmd = new DeleteGoodsByGoodsCategoryIdCommannd(@event.GoodsCategory.Id);
            return mediator.Send(cmd, cancellationToken);
        }
    }
}
